public class TestShowTwos {
    public static void main(String[] args) {
        showTwos(7);    // 7 = 7
        showTwos(18);   // 18 = 2 * 9
        showTwos(68);   // 68 = 2 * 2 * 17
        showTwos(120);  // 120 = 2 * 2 * 2 * 15
    }
    
    public static void showTwos(int x) {
        System.out.print(x + " = ");
        if (x == 2)
            System.out.print(x);
        else {
            while (x % 2 == 0) {
                System.out.print("2 * ");
                x = x / 2;
            }
            System.out.print(x);
        }
        System.out.println();
    }
}